package com.study.example.gameserver.serverinfo.entity;

import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.util.Objects;

public class ServerInfoId implements Serializable, Comparable<ServerInfoId> {
    private Integer serverId;
    private String infoKey;

    public ServerInfoId() {
    }

    public ServerInfoId(Integer serverId, String infoKey) {
        this.serverId = serverId;
        this.infoKey = infoKey;
    }

    public static ServerInfoId of(int serverId, String infoKey) {
        return new ServerInfoId(serverId, infoKey);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ServerInfoId)) return false;
        ServerInfoId that = (ServerInfoId) o;
        return Objects.equals(serverId, that.serverId) &&
                Objects.equals(infoKey, that.infoKey);
    }

    @Override
    public int hashCode() {
        return Objects.hash(serverId, infoKey);
    }

    @Override
    public int compareTo(@NotNull ServerInfoId o) {
        return this.infoKey.compareTo(o.infoKey);
    }

    public Integer getServerId() {
        return serverId;
    }

    public String getInfoKey() {
        return infoKey;
    }
}
